/* 服务器到本地一些数据的转换 */
const S2L = {
  "single": '单选',
  "multiple": '多选',
  "judge": '判断',
  "text": '填空',
  "composite": '问答',
  "easy": '简单',
  "medium": '中等',
  "hard": '困难',
  "custom": '自由选择',
  "random": '随机生成'
}

/* Quest 部分的数据格式化 */
export const quest_fmt_getQuestions = function (data) {
  return data.map(item => {
    let o = {};
    o.id = item.id;
    o.type = S2L[item.type];
    o.degree = S2L[item.difficulty];
    o.name = item.title;
    o.class = item.category ? item.category.name : '';
    o.literature = '';
    o.intend = item.saas_user_id;
    o.tag = '';
    o.updateTime = item.updated_at;
    o.createTime = item.created_at;
    return o;
  })
}
export const quest_fmt_getQuestClass = function (data) {
  return data.map(item => {
    let o = {};
    o.id = item.id;
    o.name = item.name;
    o.updateTime = item.updated_at;
    o.createTime = item.created_at;
    return o;
  })
}
export const quest_fmt_getLabellist = function (data) {
  return data.map(item => {
    let o = {};
    o.id = item.id;
    o.name = item.name;
    o.updateTime = item.updated_at;
    o.createTime = item.created_at;
    o.saas_user_id = item.saas_user_id;
    return o;
  })
}
/* Test 部分的数据格式化 */
export const test_fmt_getTests = function (data) {
  return data.map(item => {
    let o = {};
    o.id = item.id;
    o.type = S2L[item.type];
    o.name = item.name;
    o.class = item.category ? item.category.name : '';
    o.score = item.total_score;

    o.publish = item.publish==1? '已发布':'未发布';
    o.updateTime = item.updated_at;
    o.createTime = item.created_at;
    o.fontType = {
      publish: item.publish==1? 'success':'danger'
    }
    return o;
  })
}
export const test_fmt_getTestClass = function (data) {
  return data.map(item => {
    let o = {};
    o.id = item.id;
    o.name = item.name;
    o.description = item.description;
    o.phone = item.phone;
    o.location = item.location;
    o.image = item.image;
    o.works_description = item.works_description;
    o.saas_user_id = item.saas_user_id;
    o.order = item.order;
    o.all_child_id = item.all_child_id;

    return o;
  })
}
/* 管理 部分的数据格式化 */
export const quest_fmt_getDepManage = function (data) {
  return data.map(item => {
    let o = {};
    o.id = item.id;
    o.name = item.name;
    o.updateTime = item.updated_at;
    o.createTime = item.created_at;
    o.saas_user_id = item.saas_user_id;

    return o;
  })
}
export const quest_fmt_getUserManage = function (data) {
  return data
}
/* Exam 部分的数据格式化 */
export const exam_fmt_getExams = function (data) {
  return data.map(item => {
    let o = {};
    o.id = item.id;
    o.name = item.name;
    o.publish = item.publish==1? '已发布':'未发布';
    o.updateTime = item.updated_at;
    o.createTime = item.created_at;
    o.fontType = {
      publish: item.publish==1? 'success':'danger'
    }
    return o;
  })
}
export const exam_fmt_getMyExams = function (data) {
  return data.map(item => {
    let o = {};
    o.id = item.id;
    o.name = item.name;
    o.startTime = item.startTime;
    o.endTime = item.endTime;
    o.finishedTime = item.active_status == -1 ? '暂未开始考试' : item.last_submit;
    o.score = item.score == null ? '暂无' : item.score;
    o.result = item.is_pass == null ? '暂无' : item.is_pass ? '通过' : '未通过';
    o.finished = item.active_status;
    return o;
  })
}
